package today.rocky.elegantcoding.common;

import today.rocky.elegantcoding.annotation.IdentityCardNumber;
import today.rocky.elegantcoding.util.IdCardValidatorUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author Rocky
 * @version 1.0
 * @date 2020/5/19 12:51
 */
public class IdentityCardNumberValidator implements ConstraintValidator<IdentityCardNumber, Object> {

	@Override
	public void initialize(IdentityCardNumber identityCardNumber) {
	}


	@Override
	public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
		return IdCardValidatorUtils.isValidate18Idcard(o.toString());
	}
}
